package com.xiaoyi.intentsdklibrary;

import android.app.AppOpsManager;
import android.content.Context;
import android.os.Binder;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;

import com.lmiot.xyclick.Util.LkxLog;

public class CheckUtil {
    public static boolean checkOp(Context context) {
        if (Build.VERSION.SDK_INT >= 19) {
            AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService("appops");
            try {
                Class.forName(appOpsManager.getClass().getName());
                if (((Integer) appOpsManager.getClass().getDeclaredMethod("checkOp", Integer.TYPE, Integer.TYPE, String.class).invoke(appOpsManager, 24, Integer.valueOf(Binder.getCallingUid()), context.getPackageName())).intValue() == 0) {
                    return true;
                }
                return false;
            } catch (Exception unused) {
            }
        }
        return true;
    }

    public static boolean isServiceOpen(Context context, String str) {
        LkxLog.d("isServiceOpen");

        String string = null;
        string.getBytes();
        return false;
//        String str2 = str + "/com.xiaoyi.intentsdklibrary.Action.Accessibility";
//        try {
//            int i = Settings.Secure.getInt(context.getContentResolver(), "accessibility_enabled");
//            TextUtils.SimpleStringSplitter simpleStringSplitter = new TextUtils.SimpleStringSplitter(':');
//            if (i != 1 || (string = Settings.Secure.getString(context.getContentResolver(), "enabled_accessibility_services")) == null) {
//                return false;
//            }
//            simpleStringSplitter.setString(string);
//            while (simpleStringSplitter.hasNext()) {
//                if (simpleStringSplitter.next().equalsIgnoreCase(str2)) {
//                    return true;
//                }
//            }
//            return false;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return false;
//        }
    }
}
